package com.hexacta.hrs.report.dtos;

import java.text.DecimalFormat;
import java.util.Date;

import com.hexacta.hrs.domain.staffing.assignment.AvailabilityStatus;

/**
 * 
 * @author nscuri
 * 
 */
public class ResourcesAssignmentDTO implements Comparable<ResourcesAssignmentDTO> {

    private static final String ADD_ON_AVAILABLE_LABEL = "Add On Available";

    private static final String ADD_ON_NOT_AVAILABLE_LABEL = "Add On Not Available";

    private static final String ASIGNADO_CLIENTE_LABEL = "Asignado Cliente";

    private static final String INTERNO_LABEL = "Interno";

    private static final String NO_ASIGNADO_LABEL = "No Asignado";

    private static final String TOTAL = "Total";

    private static final DecimalFormat twoDForm = new DecimalFormat("#.##");

    private String assignmentType;

    private String month1 = " ";

    private String percentage1 = "0.00";

    private String year1 = " ";

    private Double amount1 = 0.00;

    private String month2 = " ";

    private String percentage2 = "0.00";

    private String year2 = " ";

    private Double amount2 = 0.00;

    private String month3 = " ";

    private String percentage3 = "0.00";

    private String year3 = " ";

    private Double amount3 = 0.00;

    private String month4 = " ";

    private String percentage4 = "0.00";

    private String year4 = " ";

    private Double amount4 = 0.00;

    private String month5 = " ";

    private String percentage5 = "0.00";

    private String year5 = " ";

    private Double amount5 = 0.00;

    private String month6 = " ";

    private String percentage6 = "0.00";

    private String year6 = " ";

    private Double amount6 = 0.00;

    private String month7 = " ";

    private String percentage7 = "0.00";

    private String year7 = " ";

    private Double amount7 = 0.00;

    private String month8 = " ";

    private String percentage8 = "0.00";

    private String year8 = " ";

    private Double amount8 = 0.00;

    private String month9 = " ";

    private String percentage9 = "0.00";

    private String year9 = " ";

    private Double amount9 = 0.00;

    private String month10 = " ";

    private String percentage10 = "0.00";

    private String year10 = " ";

    private Double amount10 = 0.00;

    private String month11 = " ";

    private String percentage11 = "0.00";

    private String year11 = " ";

    private Double amount11 = 0.00;

    private String month12 = " ";

    private String percentage12 = "0.00";

    private String year12 = " ";

    private Double amount12 = 0.00;

    public ResourcesAssignmentDTO(final String type) {
        assignmentType = type;
    }

    @Override
    public int compareTo(final ResourcesAssignmentDTO o) {
        // TODO Auto-generated method stub
        return 0;
    }

    public String getMonth1() {
        return month1 + "/" + year1;
    }

    public void setMonth1(final String month1) {
        this.month1 = month1;
    }

    public String getYear1() {
        return year1;
    }

    public void setYear1(final String year1) {
        this.year1 = year1;
    }

    public Double getiAmount1() {
        return amount1;
    }

    public void setAmount1(final Double amount1) {
        this.amount1 = amount1;
    }

    public String getMonth2() {
        return month2 + "/" + year2;
    }

    public void setMonth2(final String month2) {
        this.month2 = month2;
    }

    public String getYear2() {
        return year2;
    }

    public void setYear2(final String year2) {
        this.year2 = year2;
    }

    public Double getiAmount2() {
        return amount2;
    }

    public void setAmount2(final Double amount2) {
        this.amount2 = amount2;
    }

    public String getMonth3() {
        return month3 + "/" + year3;
    }

    public void setMonth3(final String month3) {
        this.month3 = month3;
    }

    public String getYear3() {
        return year3;
    }

    public void setYear3(final String year3) {
        this.year3 = year3;
    }

    public Double getiAmount3() {
        return amount3;
    }

    public void setAmount3(final Double amount3) {
        this.amount3 = amount3;
    }

    public String getMonth4() {
        return month4 + "/" + year4;
    }

    public void setMonth4(final String month4) {
        this.month4 = month4;
    }

    public String getYear4() {
        return year4;
    }

    public void setYear4(final String year4) {
        this.year4 = year4;
    }

    public Double getiAmount4() {
        return amount4;
    }

    public void setAmount4(final Double amount4) {
        this.amount4 = amount4;
    }

    public String getMonth5() {
        return month5 + "/" + year5;
    }

    public void setMonth5(final String month5) {
        this.month5 = month5;
    }

    public String getYear5() {
        return year5;
    }

    public void setYear5(final String year5) {
        this.year5 = year5;
    }

    public Double getiAmount5() {
        return amount5;
    }

    public void setAmount5(final Double amount5) {
        this.amount5 = amount5;
    }

    public String getMonth6() {
        return month6 + "/" + year6;
    }

    public void setMonth6(final String month6) {
        this.month6 = month6;
    }

    public String getYear6() {
        return year6;
    }

    public void setYear6(final String year6) {
        this.year6 = year6;
    }

    public Double getiAmount6() {
        return amount6;
    }

    public void setAmount6(final Double amount6) {
        this.amount6 = amount6;
    }

    public String getMonth7() {
        return month7 + "/" + year7;
    }

    public void setMonth7(final String month7) {
        this.month7 = month7;
    }

    public String getYear7() {
        return year7;
    }

    public void setYear7(final String year7) {
        this.year7 = year7;
    }

    public Double getiAmount7() {
        return amount7;
    }

    public void setAmount7(final Double amount7) {
        this.amount7 = amount7;
    }

    public String getMonth8() {
        return month8 + "/" + year8;
    }

    public void setMonth8(final String month8) {
        this.month8 = month8;
    }

    public String getYear8() {
        return year8;
    }

    public void setYear8(final String year8) {
        this.year8 = year8;
    }

    public Double getiAmount8() {
        return amount8;
    }

    public void setAmount8(final Double amount8) {
        this.amount8 = amount8;
    }

    public String getMonth9() {
        return month9 + "/" + year9;
    }

    public void setMonth9(final String month9) {
        this.month9 = month9;
    }

    public String getYear9() {
        return year9;
    }

    public void setYear9(final String year9) {
        this.year9 = year9;
    }

    public Double getiAmount9() {
        return amount9;
    }

    public void setAmount9(final Double amount9) {
        this.amount9 = amount9;
    }

    public String getMonth10() {
        return month10 + "/" + year10;
    }

    public void setMonth10(final String month10) {
        this.month10 = month10;
    }

    public String getYear10() {
        return year10;
    }

    public void setYear10(final String year10) {
        this.year10 = year10;
    }

    public Double getiAmount10() {
        return amount10;
    }

    public void setAmount10(final Double amount10) {
        this.amount10 = amount10;
    }

    public String getMonth11() {
        return month11 + "/" + year11;
    }

    public void setMonth11(final String month11) {
        this.month11 = month11;
    }

    public String getYear11() {
        return year11;
    }

    public void setYear11(final String year11) {
        this.year11 = year11;
    }

    public Double getiAmount11() {
        return amount11;
    }

    public void setAmount11(final Double amount11) {
        this.amount11 = amount11;
    }

    public String getMonth12() {
        return month12 + "/" + year12;
    }

    public void setMonth12(final String month12) {
        this.month12 = month12;
    }

    public String getYear12() {
        return year12;
    }

    public void setYear12(final String year12) {
        this.year12 = year12;
    }

    public Double getiAmount12() {
        return amount12;
    }

    public void setAmount12(final Double amount12) {
        this.amount12 = amount12;
    }

    public void setAssignmentType(final String assignmentType) {
        this.assignmentType = assignmentType;
    }

    public String getAssignmentType() {
        return assignmentType;
    }

    public String getPercentage1() {
        return percentage1 + "%";
    }

    public void setPercentage1(final String percentage1) {
        this.percentage1 = percentage1;
    }

    public String getPercentage2() {
        return percentage2 + "%";
    }

    public void setPercentage2(final String percentage2) {
        this.percentage2 = percentage2;
    }

    public String getPercentage3() {
        return percentage3 + "%";
    }

    public void setPercentage3(final String percentage3) {
        this.percentage3 = percentage3;
    }

    public String getPercentage4() {
        return percentage4 + "%";
    }

    public void setPercentage4(final String percentage4) {
        this.percentage4 = percentage4;
    }

    public String getPercentage5() {
        return percentage5 + "%";
    }

    public void setPercentage5(final String percentage5) {
        this.percentage5 = percentage5;
    }

    public String getPercentage6() {
        return percentage6 + "%";
    }

    public void setPercentage6(final String percentage6) {
        this.percentage6 = percentage6;
    }

    public String getPercentage7() {
        return percentage7 + "%";
    }

    public void setPercentage7(final String percentage7) {
        this.percentage7 = percentage7;
    }

    public String getPercentage8() {
        return percentage8 + "%";
    }

    public void setPercentage8(final String percentage8) {
        this.percentage8 = percentage8;
    }

    public String getPercentage9() {
        return percentage9 + "%";
    }

    public void setPercentage9(final String percentage9) {
        this.percentage9 = percentage9;
    }

    public String getPercentage10() {
        return percentage10 + "%";
    }

    public void setPercentage10(final String percentage10) {
        this.percentage10 = percentage10;
    }

    public String getPercentage11() {
        return percentage11 + "%";
    }

    public void setPercentage11(final String percentage11) {
        this.percentage11 = percentage11;
    }

    public String getPercentage12() {
        return percentage12 + "%";
    }

    public void setPercentage12(final String percentage12) {
        this.percentage12 = percentage12;
    }

    public String getAmount1() {
        // return twoDForm.format(amount1);
        return amount1.toString();
    }

    public String getAmount2() {
        // return twoDForm.format(amount2);
        return amount2.toString();
    }

    public String getAmount3() {
        // return twoDForm.format(amount3);
        return amount3.toString();
    }

    public String getAmount4() {
        // return twoDForm.format(amount4);
        return amount4.toString();
    }

    public String getAmount5() {
        // return twoDForm.format(amount5);
        return amount5.toString();
    }

    public String getAmount6() {
        // return twoDForm.format(amount6);
        return amount6.toString();
    }

    public String getAmount7() {
        // return twoDForm.format(amount7);
        return amount7.toString();
    }

    public String getAmount8() {
        // return twoDForm.format(amount8);
        return amount8.toString();
    }

    public String getAmount9() {
        // return twoDForm.format(amount9);
        return amount9.toString();
    }

    public String getAmount10() {
        // return twoDForm.format(amount10);
        return amount10.toString();
    }

    public String getAmount11() {
        // return twoDForm.format(amount11);
        return amount11.toString();
    }

    public String getAmount12() {
        // return twoDForm.format(amount12);
        return amount12.toString();
    }

    @SuppressWarnings("deprecation")
    public void setMonthAndYear(final int month, final Date actual) {
        setMonth(month, Integer.valueOf(actual.getMonth() + 1).toString());
        setYear(month, Integer.valueOf(actual.getYear() + 1900).toString());
    }

    public double getAmount(final int index) {
        switch (index) {
        case 0:
            return Double.valueOf(amount1);
        case 1:
            return Double.valueOf(amount2);
        case 2:
            return Double.valueOf(amount3);
        case 3:
            return Double.valueOf(amount4);
        case 4:
            return Double.valueOf(amount5);
        case 5:
            return Double.valueOf(amount6);
        case 6:
            return Double.valueOf(amount7);
        case 7:
            return Double.valueOf(amount8);
        case 8:
            return Double.valueOf(amount9);
        case 9:
            return Double.valueOf(amount10);
        case 10:
            return Double.valueOf(amount11);
        case 11:
            return Double.valueOf(amount12);
        }
        return 0;
    }

    public void calculatePercentages(final double total, final int index) {
        Double percentage = getAmount(index) * 100 / total;
        setPercentage(percentage.toString(), index);
    }

    private void setPercentage(final String value, final int index) {
        switch (index) {
        case 0:
            percentage1 = twoDForm.format(Double.valueOf(value));
            break;
        case 1:
            percentage2 = twoDForm.format(Double.valueOf(value));
            break;
        case 2:
            percentage3 = twoDForm.format(Double.valueOf(value));
            break;
        case 3:
            percentage4 = twoDForm.format(Double.valueOf(value));
            break;
        case 4:
            percentage5 = twoDForm.format(Double.valueOf(value));
            break;
        case 5:
            percentage6 = twoDForm.format(Double.valueOf(value));
            break;
        case 6:
            percentage7 = twoDForm.format(Double.valueOf(value));
            break;
        case 7:
            percentage8 = twoDForm.format(Double.valueOf(value));
            break;
        case 8:
            percentage9 = twoDForm.format(Double.valueOf(value));
            break;
        case 9:
            percentage10 = twoDForm.format(Double.valueOf(value));
            break;
        case 10:
            percentage11 = twoDForm.format(Double.valueOf(value));
            break;
        case 11:
            percentage12 = twoDForm.format(Double.valueOf(value));
            break;
        }

    }

    public void setMonth(final int numberMonth, final String value) {
        switch (numberMonth) {
        case 0:
            month1 = value;
            break;
        case 1:
            month2 = value;
            break;
        case 2:
            month3 = value;
            break;
        case 3:
            month4 = value;
            break;
        case 4:
            month5 = value;
            break;
        case 5:
            month6 = value;
            break;
        case 6:
            month7 = value;
            break;
        case 7:
            month8 = value;
            break;
        case 8:
            month9 = value;
            break;
        case 9:
            month10 = value;
            break;
        case 10:
            month11 = value;
            break;
        case 11:
            month12 = value;
        }
    }

    public void setYear(final int numberYear, final String value) {
        switch (numberYear) {
        case 0:
            year1 = value;
            break;
        case 1:
            year2 = value;
            break;
        case 2:
            year3 = value;
            break;
        case 3:
            year4 = value;
            break;
        case 4:
            year5 = value;
            break;
        case 5:
            year6 = value;
            break;
        case 6:
            year7 = value;
            break;
        case 7:
            year8 = value;
            break;
        case 8:
            year9 = value;
            break;
        case 9:
            year10 = value;
            break;
        case 10:
            year11 = value;
            break;
        case 11:
            year12 = value;
        }
    }

    public void increment(final int month, final double amount) {
        switch (month) {
        case 0:
            amount1 = amount1 + amount;
            break;
        case 1:
            amount2 = amount2 + amount;
            break;
        case 2:
            amount3 = amount3 + amount;
            break;
        case 3:
            amount4 = amount4 + amount;
            break;
        case 4:
            amount5 = amount5 + amount;
            break;
        case 5:
            amount6 = amount6 + amount;
            break;
        case 6:
            amount7 = amount7 + amount;
            break;
        case 7:
            amount8 = amount8 + amount;
            break;
        case 8:
            amount9 = amount9 + amount;
            break;
        case 9:
            amount10 = amount10 + amount;
            break;
        case 10:
            amount11 = amount11 + amount;
            break;
        case 11:
            amount12 = amount12 + amount;
        }
    }

    public String getTypeLabel() {

        if (assignmentType.equals(AvailabilityStatus.AddOnAvailable.toString()))
            return ADD_ON_AVAILABLE_LABEL;

        if (assignmentType.equals(AvailabilityStatus.AddOnNotAvailable.toString()))
            return ADD_ON_NOT_AVAILABLE_LABEL;

        if (assignmentType.equals(AvailabilityStatus.AsignadoCliente.toString()))
            return ASIGNADO_CLIENTE_LABEL;

        if (assignmentType.equals(AvailabilityStatus.Interno.toString()))
            return INTERNO_LABEL;

        if (assignmentType.equals(AvailabilityStatus.NoAsignado.toString()))
            return NO_ASIGNADO_LABEL;

        if (assignmentType.equalsIgnoreCase(TOTAL))
            return TOTAL;

        return "";
    }

}
